package com.yangfan.thread.thread_wangwenjun09;

import java.util.Random;

/**
 * @description: 发送请求的 客户端
 * @author: yangfan
 * @date: Created in 2020/2/12 0012 14:49
 * @modified By:
 */
public class ClientThread extends Thread {

    private final RequestServer server;

    private final String sendValue;

    public ClientThread(RequestServer server, String sendValue) {
        this.server = server;
        this.sendValue = sendValue;
    }

    @Override
    public void run() {


        for (int i = 0; i < 10; i++) {
            System.out.println("客户端发出请求: "+sendValue);
            server.putRequest(new Request(sendValue));

            try {
                Thread.sleep(new Random().nextInt(1_000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }

    }



}
